package com.xbang.attendance.service;

import java.util.List;
import java.util.Map;
import java.util.Set;

import com.xbang.attendance.entity.order.DeliveryOrder;
import com.xbang.attendance.entity.order.PurchaseDetails;
import com.xbang.attendance.entity.order.PurchaseOrder;
import com.xbang.attendance.helper.importexcel.PurchaseImportHelper;
import com.xbang.core.service.BaseService;

/**
 * @author huawei
 * @email alonelaval@gmail.com
 */
public interface PurchaseOrderService extends BaseService {

	/**
	 * 得到排序的最大值
	 */
	int getMaxOrder() throws Exception;

	/***
	 * 根据PO单号，判断是否存在
	 * 
	 * @param code
	 * @return
	 * @throws Exception
	 */
	Boolean isPurchaseExist(String code) throws Exception;

	/**
	 * 删除采购订单
	 * 
	 * @param id
	 * @return
	 * @throws Exception
	 */
	List<Map<String, Object>> deletePurchaseOrder(Integer id) throws Exception;

	/**
	 * 得到PO
	 * 
	 * @param id
	 *            key
	 * @return
	 * @throws Exception
	 */
	PurchaseOrder getPurchaseOrderByKey(Integer id) throws Exception;

	/**
	 * 得到明细
	 * 
	 * @param id
	 * @return
	 */
	PurchaseDetails getDetailsByKey(Integer id);

	/**
	 * 将某个PO根据规则声称Delivery Order
	 * 
	 * @param purchaseOrder
	 *            订单
	 * @return
	 * @throws Exception
	 */
	DeliveryOrder convertDeliveryOrder(PurchaseOrder purchaseOrder) throws Exception;

	/**
	 * 将某个PO根据规则生成Delivery Order
	 * 
	 * @param purchaseOrder
	 * @param purchaseDetails
	 * @return
	 * @throws Exception
	 */
	DeliveryOrder convertDeliveryOrder(PurchaseOrder purchaseOrder, Set<PurchaseDetails> purchaseDetails) throws Exception;

	/***
	 * 得到所有的PO 因为现在没有考虑分页，所有就将所有的查出来
	 * 
	 * @return
	 * @throws Exception
	 */
	List<PurchaseOrder> getAllPurchaseOrders() throws Exception;

	/**
	 * 根据web路径生成excel,并返回该文件的名称
	 * 
	 * @param webPath
	 *            服务器路径
	 * @return
	 * @throws Exception
	 */
	String genericExcelFile(String webPath, String[] fields) throws Exception;

	/***
	 * 更新PO
	 * 
	 * @param purchaseImportHelper
	 * @throws Exception
	 */
	void updatePurchaseOrder(PurchaseImportHelper purchaseImportHelper) throws Exception;

	/**
	 * 更新订单完成百分比
	 * 
	 * @throws Exception
	 */
	void updatePurchaseOrderPercent() throws Exception;

	/***
	 * 更新百分比
	 * 
	 * @param purchaseOrder
	 * @throws Exception
	 */
	void updatePurchaseOrderPercent(PurchaseOrder purchaseOrder) throws Exception;

	/***
	 * 产生送货单excel文件
	 * 
	 * @param webPath
	 *            web路径
	 * @param templatePath
	 *            模板路径
	 * @return 文件路径
	 * @throws Exception
	 */
	String genericExcelFile(String webPath, String id, String[] ids) throws Exception;
}
